<template>
  <div class="sheep_class pad15 hei00 box flex col">
    <div class="flex_middle titles pad_l5">
      <dv-decoration-6 style="width: 45px; height: 20px" />
      <div class="mar_l10">城市老龄幼儿人数对比</div>
    </div>
    <div class="concent flex1 hei00">
      <div class="pre" id="main_four"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  mounted() {
    this.onepie();
  },
  methods: {
    onepie() {
      var chartDom = document.getElementById("main_four");
      var myChart = echarts.init(chartDom);
      var option = {
        // 提示
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ['老龄人数', '幼儿人数'],
          textStyle: {
            color: '#fff'
          },
          bottom: '2%'
        },
        // 横轴
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: [
            "1月",
            "2月",
            "3月",
            "4月",
            "5月",
            "6月",
            "7月",
            "8月",
            "9月",
            "10月",
            "11月",
            "12月",
          ],
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
          splitLine: {
            show: false,
          },
        },
        // 纵轴
        yAxis: {
          type: "value",
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
          splitLine: {
            show: false,
          },
        },
        grid: {
          left: 20,
          right: 20,
          bottom: 35,
          containLabel: true,
        },
        series: [
          {
            data: [673,723,695,775,689,810,835,687,783,812,912,688],
            type: "line",
            name: "老龄人数", // 提示名字
            smooth: true, // 是否变成曲线
            itemStyle: {
              color: "#3158ff",
            },
            areaStyle: {
              //区域填充渐变颜色
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#3158ff", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "rgba(83, 97, 255, 0)", // 100% 处的颜色
                  },
                ],
                global: false, // 缺省为 false
              },
            },
          },
          {
            data: [773,823,795,875,789,910,935,787,883,912,952,788],
            type: "line",
            name: "幼儿人数", // 提示名字
            smooth: true, // 是否变成曲线
            itemStyle: {
              color: "#41f8ff",
            },
            areaStyle: {
              //区域填充渐变颜色
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#41f8ff", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "rgba(83, 97, 255, 0)", // 100% 处的颜色
                  },
                ],
                global: false, // 缺省为 false
              },
            },
          },
        ],
      };
      option && myChart.setOption(option);
      window.addEventListener("resize", function() {
        myChart.resize();
      });
    },
  },
};
</script>
<style scoped lang="scss">
.sheep_class {
  .concent {
    .pre {
      width: 100%;
      height: 100%;
    }
  }
  .titles {
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
  }
}
</style>
